/***********************************************
 * Title:       IbatisClassDao.java
 * Description: TODO ADD DISCRIPTION TO IbatisClassDao.java
 * Author:      Administrator
 * Create Date: 2009-12-20
 * CopyRight:   CopyRight(c)@2009
 * Version:     1.0
 ***********************************************
 */

package edu.tju.classes;

import java.sql.SQLException;

import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;

import com.younker.waf.db.IBatisConfig;

import edu.tju.model.TheClass;

/**
 * @author LeiKang
 *
 */
public class IbatisTheClassDao implements ITheClassDao{
	
	protected SqlMapClient sqlMap = IBatisConfig.getSqlMapInstance();	 
	 
	   @SuppressWarnings("unchecked")
	public double getAvgZKScore(ZKScore zkScore)throws SQLException 
       {       
       	   double avg=0;
       	   
		   @SuppressWarnings("unused")
		   List<ZKScore> zk=(List<ZKScore>)sqlMap.queryForObject("getZKScoreAnd",zkScore.getStudentId());
		   
		   return avg;
	       
       }

	/* (non-Javadoc)
	 * @see edu.tju.classes.ITheClassDao#deleteTheClass(long)
	 */
	public void deleteTheClass(long id) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see edu.tju.classes.ITheClassDao#getTheClassAnd(edu.tju.model.TheClass)
	 */
	@SuppressWarnings("unchecked")
	public List<TheClass> getTheClassAnd(TheClass theClass) throws SQLException {
		
		return sqlMap.queryForList("getTheClassAnd", theClass);
		
	}


	/* (non-Javadoc)
	 * @see edu.tju.classes.ITheClassDao#getTheClassById(long)
	 */
	public TheClass getTheClassById(long id) throws SQLException {
	
		 return (TheClass) sqlMap.queryForObject("getTheClassById", id);
		 
	}


	/* (non-Javadoc)
	 * @see edu.tju.classes.ITheClassDao#getTheClassOr(edu.tju.model.TheClass)
	 */
	public List<TheClass> getTheClassOr(TheClass theClass) throws SQLException {
		// TODO Auto-generated method stub
		return null;
		
	}


	/* (non-Javadoc)
	 * @see edu.tju.classes.ITheClassDao#insertTheClass(edu.tju.model.TheClass)
	 */
	public Long insertTheClass(TheClass theClass) throws SQLException {
		
		return  (Long)sqlMap.insert("insertTheClass", theClass); 
		
	}


	/* (non-Javadoc)
	 * @see edu.tju.classes.ITheClassDao#updateTheClass(edu.tju.model.TheClass)
	 */
	public int updateTheClass(TheClass theClass) throws SQLException {
		// TODO Auto-generated method stub
		return sqlMap.update("updateTheClass", theClass);
		
	}
       
}
